Skip to main content

Trigger Example 2: Gluing Process

The Robotics_Trigger_Advanced.project sample project described here is located in the installation directory of CODESYS under..\CODESYS SoftMotion\Examples.

Triggers can be used to perform actions at specific positions on the path, such as switching a gluing nozzle on and off.

This example includes the following components:

  • The configuration of a guaranteed forecast of the trajectory by the fPlanningForecastDuration parameter from the SMC_TuneCPKernel function block.

  • The commanding of different triggers. Here, all three available methods for defining the path position are used (see SMC_TriggerPositionType).

  • The use of triggers with time shift. The sample application contains the TriggerWithTimeShift function block, which can react to reaching the path position with a time offset (earlier and later).

These components are shown in a sample application for a gluing process. The movement displayed in red in the following image is executed (with blending).

_sm_img_digital_switches_example.png

Triggers have been defined at the positions marked in green:

  • Position 1: Switch on the gluing device 0.05 s before reaching the position.

  • Position 1: Switch on the UV lamp when the position is reached.

  • Position 2: Fill the glue supply container when the position is reached.

  • Position 3: Switch off the gluing device and stop filling the glue supply container 0.05 s before reaching the position.

  • Position 3: Switch off the UV lamp 1.5 s after reaching the position

Structure of the application

The application consists of the following parts.

  • GlueApplication: This program contains the sample application which shows how to use of triggers for a gluing process.

  • Planning_PRG: In this program, a forecast of the trajectory is configured.

  • TriggerWithTimeShift: This function block contains the logic for triggers with a time shift and is used in the GlueApplication sample program.

  • Trace: The trace shows the dynamics of the axes and also the outputs of the GlueApplication program which are switched by the triggers.

Configuration of a forecast

If you want to react early before a trigger is reached, for example 0.05 s before, then the fPlanningForecastDuration parameter from the SMC_SMC_TuneCPKernel function block has to be set to at least 0.05 s. Because the parameter has a direct impact on the latency, its value should not be larger than necessary (see the documentation of fPlanningForecastDuration). Note that SMC_TuneCPKernel has to be called in the SoftMotion planning task. For this reason, the configuration is not executed in the main program GlueApplication, but in the Planning_PRG program.

In this sample application, the evaluation of the trigger is required at the earliest 0.05 s before a position is reached. For this reason, the parameterfPlanningForecastDuration=0.05 is set in the Planning_PRG program.

Function block: TriggerWithTimeShift

The TriggerWithTimeShift function block provides a simplified interface for using triggers. In addition, a time shift can be defined so that the trigger can react before a position (positive value) as well as after a position (negative value) is reached. Depending on the time precision required in an application, the reaction to reaching a trigger can be as follows:

  • Required time precision >= bus task cycle: In this case, the TriggerWithTimeShift.TriggerReachedThisCycle output can be used.

  • Required time precision < bus task cycle: In this case, the exact remaining time TriggerWithTimeShift.TriggerTime until the trigger is reached can be used.

Internally, TriggerWithTimeShift uses the SMC_GroupPrepareTrigger and SMC_GroupReadTrigger function blocks.

Commanding triggers

In the GlueApplication program, the movements and triggers are commanded. The call order is particularly important for triggers because the triggers prepared using SMC_GroupPrepareTrigger are assigned to the next movement commanded in the same cycle. Therefore, in every application you need to pay attention to the following:

  1. Function blocks for commanding triggers are always called before the movement function blocks.

  2. Triggers and the respective movement are always commanded in the same cycle.

The triggers use all types from SMC_TriggerPositionType:

  • The triggers at Position 1 use the definition of a relative distance (SMC_TriggerPositionType.MvtRelative) and as Position 0.5. Because the respective movement has a distance of 10, the triggers are located at X=5.

  • The trigger at Position 2 uses the definition of a distance in user units u (SMC_TriggerPositionType.MvtDistance) and as Position 5. As a result, the trigger is also located at X=5.

  • The triggers at Position 3 use the intersection with a plane (SMC_TriggerPositionType.PlaneIntersection). The plane has been defined so that the triggers are located at X=5.

GlueApplication has the EnableGlue, EnableUVLamp, and RefillGlueStorage outputs. These are switched at the appropriate triggers in GlueApplication.EvaluateTriggers(). The movement and state of these outputs can be monitored and evaluated in the trace.